package name.huzhenbo.java.methods;

import java.util.Collection;
import java.util.List;
import java.util.Set;

/**
 * Effectieve Java, Item 41, Use overloading judiciously
 * <p/>
 * The choice of which overloading to invoke is made at compile time. (whereas overriden is decided at runtime)
 * <p/>
 * 1. A safe, conservative policy is never to export two overloadings with the same number of parameters.
 * <p/>
 * For example, consider the class ObjectOutputStream. It has a variant of its
 * write method for every primitive type and for several reference types. Rather than
 * overloading the write method, these variants have signatures like writeBool-
 * ean(boolean), writeInt(int), and writeLong(long). An added benefit of this
 * naming pattern, when compared to overloading, is that it is possible to provide
 * read methods with corresponding names, for example, readBoolean(), read-
 * Int(), and readLong(). The ObjectInputStream class does, in fact, provide
 * such read methods.
 */
class CollectionClassifier {
    public String classify(Set<?> set) {
        return "set";
    }

    public String classify(List<?> list) {
        return "list";
    }

    public String classify(Collection<?> collection) {
        return "collection";
    }
}
